package com.server.llh.llhserverwork.adapter;


import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.llh.llhsuppliers.R;


public class HomeNewAdatpter extends BaseAdapter {
	String[] data = { "支付", "订餐", "订服务", "商城" };
	int[] id = { R.drawable.refount, R.drawable.fan, R.drawable.pay,
			R.drawable.progect};
	private LayoutInflater lif = null;
	private  int position;
	public HomeNewAdatpter(Context context, int position) {
		lif = LayoutInflater.from(context);
		this.position = position;
	}

	@Override
	public int getCount() {
		if (data == null || data.length == 0) {
			return 0;
		}
		return data.length;
	}

	@Override
	public Object getItem(int arg0) {
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@SuppressLint({ "ViewHolder", "InflateParams" })
	@Override
	public View getView(final int arg0, View arg1, ViewGroup arg2) {
		arg1 = lif.inflate(R.layout.home_item_view, null);
		final ImageView iv = (ImageView) arg1.findViewById(R.id.iv);
		Handler mHandler = new Handler();
		mHandler.postDelayed(new Runnable() {
			@Override
			public void run() {
				try {
					iv.setImageResource(id[arg0]);
				} catch (OutOfMemoryError e) {
					e.printStackTrace();
					Log.d("memory", "out");
				}
			}
		}, 50);
		TextView tv = (TextView) arg1.findViewById(R.id.title);
		tv.setText(data[arg0]);
		return arg1;
	}
}
